package effects;

import individual.MovingEntity;

import java.awt.*;
import java.util.ArrayList;
import java.util.List;

import javax.swing.ImageIcon;

import debugger.Debugger;
import utilities.*;
import Environment.*;

/**
 * A Mover that represents an Image.
 *
 * Only the following formats are supported: png, jpg, gif.
 *
 * @author Robert C Duvall
 */
public class Image extends MovingEntity
{
    private java.awt.Image myImage;

    
    /**
     * Construct a shape at the given position, with the given size and
     * velocity, and with the image referred to by the given filename.
     */
    public Image (Vector center,
                  Dimension size,
                  Vector velocity,
                  String fileName, 
                  Environment environment, 
                  Debugger debugger)
    {
        myCenter = center;
        mySize = size;
        myVelocity = velocity;
        myColor = Color.black;
        myTrail = new ArrayList<Vector>();
    	myEnvironment = environment;
    	isDead = false;
    	myDebugger = debugger;
        setImage(fileName);
    }


    /**
     * Construct a shape at the given position, with the given size, and 
     * with the image referred to by the given filename.
     */
    public Image (Vector center,
                  Dimension size,
                  String fileName, Environment environment, 
                  Debugger debugger)
    {
        this(center, size, new Vector(0, 0), fileName, environment, debugger);
    }


    /**
     * Set this shape's image to the image referred to by the given filename.
     */
    public void setImage (String fileName)
    {
        myImage = new ImageIcon(getClass().getResource("/" + fileName)).getImage();
    }

    
    public void update(List<MovingEntity> allMovingEntities) {
    	
    }

    /**
     * Describes how to draw the shape on the screen.
     *
     * Currently, draws the shape as an image.
     */
    public void paint (Graphics pen)
    {
        pen.drawImage(myImage,
                      (int) getCenter().x - getSize().width / 2, 
					  (int) getCenter().y - getSize().height / 2,
                      getSize().width, getSize().height,
                      null);
    }
}
